/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.toools.gwt.wmc.client.companypart.gui;

import com.google.gwt.user.client.rpc.AsyncCallback;
import java.util.Collection;
import org.toools.gwt.widget.client.bc.BasicControl;
import org.toools.gwt.widget.client.bc.BasicList;
import org.toools.gwt.widget.client.bc.BasicListener;
import org.toools.gwt.widget.client.bc.BusinessObjectPanel;
import org.toools.gwt.widget.client.cloud.TagVO;
import org.toools.gwt.wmc.client.companypart.CompanyPartServiceAsync;
import org.toools.gwt.wmc.jpa.Company;
import org.toools.gwt.wmc.jpa.CompanyPart;
import org.toools.gwt.wmc.jpa.Container;

/**
 *
 * @author Manuel
 */
public class CompanyPartControl extends BasicControl{

    public CompanyPartControl(CompanyPartServiceAsync service, Company c) {
        super(service,new org.toools.gwt.widget.client.util.Account());
        Collection<CompanyPart> companyparts = c.getCompanyParts();
        if (companyparts != null) {
            setTags(getTagVO(companyparts.toArray()));
        }
    }

    public CompanyPartControl(CompanyPartServiceAsync service, Container c) {
        super(service,new org.toools.gwt.widget.client.util.Account());
        Collection<CompanyPart> companyparts = c.getCompanyParts();
        if (companyparts != null) {
            setTags(getTagVO(companyparts.toArray()));
        }
    }

    public BusinessObjectPanel createBasicPanel(Object o) {
        return new CompanyPartPanel(o);
    }
    public BasicListener createBasicListener() {
        return new CompanyPartListener(this);
    }
    public BasicList createBasicList() {
        CompanyPartList cpl = new CompanyPartList(new TagVO[]{}, this);
        return cpl;
    }
    public TagVO getTagVO(Object bp) {
        CompanyPart cp = (CompanyPart) bp;
        TagVO result = new TagVO("" + cp.getId(), cp.getName(), 0, 0);
        result.setAttachedBusinessObject(cp);
        return result;
    }
    @Override
    public String getFilterMessage() {
        return "search by name";
    }
    @Override
    public String getTitle() {
        return "CompanyParts";
    }
    @Override
    public void addSortItem() {
        getSortListBox().clear();
        getSortListBox().addItem("name");
        getSortListBox().addItem("size");
    }
}
